﻿

//ajax service
DaAn.Service = {
    Call: function (action, args, callback, cfg) {
        //action 执行的动作
        //args 提交的参数 json对象
        //callback 执行的回调函数
        //cfg 调用配置 可省略 {async:true,type:get}
        var url = "/AjaxHandler.ashx?action=" + action+"&ran="+Math.random();

        DaAn.Ajax(url, args, callback, cfg);
    },
    UserRegister: function (account, password, email, repwd, verifyCode, callback) {
        //用户注册
        var url = DaAn.Http.AddRandomNumber("/AjaxHandler.ashx?action=userregister");
        DaAn.Ajax(url, { "account": account, "password": password, "email": email, "repwd": repwd, "verifyCode": verifyCode }, callback);
    },
    SsoLogon: function (account, password, verifyCode, jsoncallback) {
        var ssoUrl = "http://www.sso.com/DaAn.SSO/Login.aspx?ajax=true&siteid=1&account=" + account + "&password=" + password + "&verifyCode=&jsoncallback=?";
        $.getJSON(ssoUrl, function (json) {
            alert(json);
        });
    },
    UserLogin: function (account, password, verifyCode, callback) {
        //用户登录
        var url = DaAn.Http.AddRandomNumber("/AjaxHandler.ashx?action=userlogin");
        DaAn.Ajax(url, { "account": account, "password": password, "verifyCode": verifyCode }, callback);
    },
    AddUserContact: function (mobile, qq, post, msn, phone, province, city, county, unitName, unitAddress, homeAddress, street, callback) {
        //增加用户联系信息
        var url = DaAn.Http.AddRandomNumber("/AjaxHandler.ashx?action=addusercontact");
        DaAn.Ajax(url, { "mobile": mobile, "qq": qq, "post": post, "msn": msn, "phone": phone, "province": province, "city": city, "county": county, "unitName": unitName, "unitAddress": unitAddress, "homeAddress": homeAddress, "street": street }, callback);

    },
    AddUserExtend: function (idCard, birthday, age, nation, height, weight, blood, animal, constellaction, marriage, manner, educaction, professional, school, callback) {
        //增加用户扩展信息
        var url = DaAn.Http.AddRandomNumber("/AjaxHandler.ashx?action=adduserextend");
        DaAn.Ajax(url, { "idCard": idCard, "birthday": birthday, "age": age, "nation": nation, "height": height, "weight": weight,
            "blood": blood, "animal": animal, "constellaction": constellaction, "marriage": marriage, "manner": manner, "education": educaction, "professional": professional, "school": school
        }, callback);

    },
    UpdateUserPwd: function (oldPwd, newPwd, confirmPwd, callback) {
        //修改用户密码
        var url = DaAn.Http.AddRandomNumber("/AjaxHandler.ashx?action=updateUserPwd");
        DaAn.Ajax(url, { "oldPwd": oldPwd, "newPwd": newPwd, "confirmPwd": confirmPwd }, callback);

    },
    FindUserPwd: function (account, email, callback) {
        //找回密码
        var url = DaAn.Http.AddRandomNumber("/AjaxHandler.ashx?action=findUserPwd");
        DaAn.Ajax(url, { "account": account, "email": email }, callback);
    },
    ResetUserPwd: function (guid, newPwd, confirmPwd, callback) {
        //重置密码
        var url = DaAn.Http.AddRandomNumber("/AjaxHandler.ashx?action=retSetPwd");
        DaAn.Ajax(url, { "guid": guid, "newPwd": newPwd, "confirmPwd": confirmPwd }, callback);
    },
    GetMenusByUserID: function (callback) {
        //根据用户ID获得权限菜单
        var url = DaAn.Http.AddRandomNumber("/AjaxHandler.ashx?action=getusermenuitem");
        DaAn.Ajax(url, {}, callback);
    },
    AddUserBase: function (userName, realName, sex, imgurl, callback) {
        //完善用户基础信息
        var url = DaAn.Http.AddRandomNumber("/AjaxHandler.ashx?action=adduserbase");
        DaAn.Ajax(url, { "userName": userName, "realName": realName, "sex": sex, "imgurl": imgurl }, callback, { type: "post" });
    }
}
var AjaxService = DaAn.Service.Call;

